package com.wwj.my_ummary.goods.controller;


import com.wwj.my_ummary.goods.service.GoodsService;
import javax.annotation.Resource;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 商品表 前端控制器
 * </p>
 *
 * @author wwj
 * @since 2021-01-14
 */
@RestController
@RequestMapping("/goods")
public class GoodsController {



    @Resource
    private GoodsService goodsService;
    @Resource
    private KafkaTemplate kafkaTemplate;




    @RequestMapping("sellGoods")
    @ResponseBody
    public Object sellGoods(Integer gid, Integer uid){
        return goodsService.sellGoods(gid,uid);
    }

//
//    @RequestMapping("sellGoodss")
//    @ResponseBody
//    public void sellGoodss(){
//        ListenableFuture future = kafkaTemplate.send("topica","1");
//        future.addCallback(o -> System.out.println("send-消息发送成功：" + "1"), throwable -> System.out.println("消息发送失败：" + "1"));
//
//    }
//
//
//    @KafkaListener(topics = "topica",id="g2")
//    public void processMessage(ConsumerRecord<?, ?> record) {
//        System.out.println("record:"+record);
//
//        goodsService.sellGoods(1,1);
//    }

}
